"""Definition of the fcinfo content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

# -*- Message Factory Imported Here -*-
from my315ok.goodfccontent import goodfccontentMessageFactory as _

from my315ok.goodfccontent.interfaces import Ifcinfo
from my315ok.goodfccontent.config import PROJECTNAME

fcinfoSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

    atapi.StringField(
        'category',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtinfocontent.classinfocategory",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"category"),
            description=_(u""),            
        ),
        required=True,
    ),

    atapi.IntegerField(
        'rooms',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"rooms"),
            description=_(u""),
        ),
        required=True,
        validators=('isInt'),
    ),
    atapi.IntegerField(
        'tings',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"tings"),
            description=_(u""),
        ),
        validators=('isInt'),
    ),


    atapi.IntegerField(
        'weis',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"weis"),
            description=_(u""),
        ),
        validators=('isInt'),
    ),





    atapi.IntegerField(
        'price',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"price per month"),
            description=_(u""),
        ),
        validators=('isInt'),
    ),


    atapi.IntegerField(
        'size',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"area size"),
            description=_(u""),
        ),
        required=True,
        validators=('isInt'),
    ),


    atapi.StringField(
        'district',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"district"),
            description=_(u""),
        ),
        required=True,
    ),


    atapi.StringField(
        'floor',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"which floor"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'floors',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"total floors"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'phone',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"phone number"),
            description=_(u""),
        ),
    ),


    atapi.StringField(
        'person',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"contact person"),
            description=_(u""),
        ),
        required=True,
    ),


    atapi.StringField(
        'gender',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.goodfccontent.title",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"sex"),
            description=_(u""),
        ),
    ),


    atapi.TextField(
        'details',
        storage=atapi.AnnotationStorage(),
        widget=atapi.TextAreaWidget(
            label=_(u"more details"),
            description=_(u""),
        ),
    ),


))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

fcinfoSchema['title'].storage = atapi.AnnotationStorage()
fcinfoSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(fcinfoSchema, moveDiscussion=False)


class fcinfo(base.ATCTContent):
    """about fangchan chuzu,chushou,mai,etc informations"""
    implements(Ifcinfo)

    meta_type = "fcinfo"
    schema = fcinfoSchema
    _at_rename_after_creation = True

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    category = atapi.ATFieldProperty('category')

    tings = atapi.ATFieldProperty('tings')

    weis = atapi.ATFieldProperty('weis')

    rooms = atapi.ATFieldProperty('rooms')

    price = atapi.ATFieldProperty('price')

    size = atapi.ATFieldProperty('size')

    district = atapi.ATFieldProperty('district')

    floor = atapi.ATFieldProperty('floor')

    floors = atapi.ATFieldProperty('floors')

    phone = atapi.ATFieldProperty('phone')

    person = atapi.ATFieldProperty('person')

    gender = atapi.ATFieldProperty('gender')

    details = atapi.ATFieldProperty('details')


atapi.registerType(fcinfo, PROJECTNAME)
